# For using the 3D renderer, just set use_render=True in the environment config. 
# Or you can turn on the image_observation,
# which will make an offscreen renderer so we can access the rendered result by capturing frames.

from metadrive.envs.metadrive_env import MetaDriveEnv

import os

cfg = dict(image_observation=True,
           show_terrain=not os.getenv("TEST_IPYNB"),
           sensors={"main_camera": ()},
           vehicle_config=dict(image_source="main_camera"),
           window_size=(84,60)
           )

env = MetaDriveEnv(cfg)

HOME = os.path.dirname(os.path.abspath(__file__))

try:
    env.reset()
    for _ in range(1 if os.getenv("TEST_DOC") else 5):
        env.step([0, 0])
    env.capture(f"{HOME}/3d_render.png")

finally:
    env.close()


